<?php
require 'include/global.php';
require './include/validate.php';
require './include/all_left.php';
include("FCKeditor/fckeditor.php") ;

require_once 'include/advisory_db.php';

if($_GET[action]=='delete'){
     $rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE `re_id`='".$_GET[id]."' AND `re_uid`= '".$_SESSION[uid]."'");
     if(empty($rs)){
	  echo "DATABASE ERROR";
	  exit;
	 }
     $sql = "DELETE FROM " . $db_prefix . "resume WHERE `re_id`=".$_GET[id];
     $DB->query($sql);
}

$smarty->display('header.tpl');
$smarty->display('allleft.tpl');
include ("./check/checkpostresume.php");
        if($status != 1)
        {
			if($_SESSION[usertype]=="candidate"||$_SESSION[usertype]=="advisor"){
				$rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='".$_SESSION[usertype]."' AND re_uid ='" . $_SESSION[uid]."' ORDER BY re_regtime ASC ");
			}
			if($_SESSION[usertype]=="recruiter"&&$_GET[id]!=''){
				$rs = $DB->fetch_one_array("SELECT * FROM " . $db_prefix . "resume WHERE re_usertype='".$_SESSION[usertype]."' AND re_uid ='" . $_SESSION[uid]."' AND re_id='".$_GET[id]."'");
			}
		//print_r($rs);
			$re_id    = $rs[re_id];
			$re_fname = $rs[re_fname];
            $re_lname = $rs[re_lname];
            $re_email = $rs[re_email];
            $re_address1 = $rs[re_address1];
            $re_address2 = $rs[re_address2];
            $re_lostate = $rs[re_lostate];
            $re_locountry = $rs[re_locountry];
            $re_locity = $rs[re_locity];
            $re_phone1 = $rs[re_phone1];
            $re_phone2 = $rs[re_phone2];
            $re_jobtype = $rs[re_jobtype];
            $re_jobindustry = $rs[re_jobindustry];
            $re_jobtitle = $rs[re_jobtitle];
            $re_yearexp = $rs[re_yearexp];
            $re_edulevel = $rs[re_edulevel];
            $re_proflicense = $rs[re_proflicense];
            $re_mgmt = $rs[re_mgmt];
            $re_profit = $rs[re_profit];
            $re_spoken = $rs[re_spoken];
            $re_prolang = $rs[re_prolang];
            $re_ip = $rs[re_ip];
            $re_ussecurity = $rs[re_ussecurity];
            $re_authorize = $rs[re_authorize];
            $re_detail = $rs[re_detail];
            $re_comments = $rs[re_comments];
			$re_regtime  = $rs[re_regtime];
			$re_upload   = $rs[re_upload];
			$re_jobsearchstatus = $rs[re_jobsearchstatus];
			$re_describeme = $rs[re_describeme];
			$re_favoriatebook = $rs[re_favoriatebook];
			$re_highachieve = $rs[re_highachieve];
			$re_iplan = $rs[re_iplan];
			$re_iliketo = $rs[re_iliketo];
			$re_comments = $rs[re_comments];
			$re_prvemployer = $rs[re_prvemployer];
			$re_prvempstatus = $rs[re_prvempstatus];
			$re_professavilable = $rs[re_professavilable];
			$re_currentpay  = $rs[re_currentpay];
			$re_desiredpay= $rs[re_desiredpay];
			$re_benefits= $rs[re_benefits];
			$re_schoolattend= $rs[re_schoolattend];
			$re_personalweb = $rs[re_personalweb];
			$re_private     = $rs[re_private];
			$re_updtime     = $rs[re_updtime];
			$re_sponsorship = $rs[re_sponsorship];
        }
		
        if($re_regtime==''){   
			$re_regtime = time();
		}
		if(empty($_GET[id])){
		  $editid = $re_id;
		}else{
	      $editid = $_GET[id];
		}

		ob_clean();
		ob_start();
    /*
		echo '	
		<script type="text/javascript" src="include/textarealimited/Bs_Misc.lib.js"></script>
		<script type="text/javascript" src="include/textarealimited/Bs_LimitedTextarea.class.js"></script>
		<script type="text/javascript" src="include/textarealimited/Bs_ColorUtil.lib.js"></script>
		<script>
		function init() {
			myLimitedFoo = new Bs_LimitedTextarea(\'re_detail\', 5000);
			myLimitedFoo.setBgColorWarning();
			myLimitedFoo.draw();
		}

		</script>';
	*/
	//back to submitapplicant
	if($re_locountry == ''){
		$re_locountry = 211;
	}


     $return = ($_POST['return'])?$_POST['return']:$_GET['return'];

		$cpforms->formheader(array ('title' => 'Candidate Record','name' => 'article','enctype' => 'multipart/form-data'));
		$cpforms->makehidden(array ('name' => 'action','value' => 'resume_doupdate'));
		$cpforms->makehidden(array ('name' => 'editid','value'=>$editid ));
		$cpforms->makehidden(array ('name' => 'return','value'=>$return));
		$cpforms->gethightext(array ('text' => "Create Date",'value' => date("m/d/Y",$re_regtime), 'view' => 1));
		if($re_updtime==0){$re_updtime = $re_regtime;}
		$cpforms->gethightext(array('text'=>"Last Updated",'value'=>date("m/d/Y",$re_updtime),'view'=>"1"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Job Search Status",'name' => "re_jobsearchstatus",'option' => $jobSearchStatus,'only' => 1,'selected' => "$re_jobsearchstatus",'view' => "$view" ,'icon'=>"'Indicate  job search status.  You may edit this later.', WIDTH, 200, SHADOW, true"));

		$cpforms->longline(array('title'=>"Contact Information"));
		$cpforms->gethightext(array ('text' => "First Name",'name' => "re_fname",'only' => 1,'value' => "$re_fname",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Last Name",'name' => "re_lname",'only' => 1,'value' => "$re_lname",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Contact Email",'name' => "re_email",'only' => 1,'value' => "$re_email",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Street Address 1",'name' => "re_address1",'only' => 1,'value' => "$re_address1",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Street Address 2",'name' => "re_address2",'value' => "$re_address2",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Location - City",'only' => 1,'name' => "re_locity",'value' => "$re_locity",'view' => "$view"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Location - State",'name' => "re_lostate",'only' => 1,'option' => $state,'selected' => "$re_lostate",'view' => "$view",'viewfunction' => 'state'));
		$cpforms->makeselect(array ('one'=>1,'text' => "Location - Country",'name' => "re_locountry",'only' => 1,'option' => $country,'selected' => "$re_locountry",'view' => "$view",'viewfunction' => 'country'));
		$cpforms->gethightext(array ('text' => "Primary Phone",'name' => "re_phone1",'only' => 1,'value' => "$re_phone1",'view' => "$view"));
		$cpforms->maketextarea(array ('text' => "Recruiter Contact",'id'=>"re_phone2",'name' => "re_phone2",'value' => "$re_phone2",'view' => "$view",'icon'=>"'Include recruiter contact information here.  Leave blank if not applicable.', WIDTH, 200, SHADOW, true"));

		$cpforms->longline(array('title'=>"Desired Job Detail"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Desired Job Type",'name' => "re_jobtype",'option' => $jobtype,'only' => 1,'selected' => "$re_jobtype",'view' => "$view"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Desired Job Category/Industry",'name' => "re_jobindustry",'option' => $jobcategory,'only' => 1,'selected' => "$re_jobindustry",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Desired Job Title",'name' => "re_jobtitle",'only' => 1,'value' => "$re_jobtitle",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Current Base Pay",'name' => "re_currentpay",'value' => "$re_currentpay",'view' => "$view",'icon'=>"'Indicate current annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)","size"=>"10"));
		$cpforms->gethightext(array ('text' => "Desired Base Pay",'name' => "re_desiredpay",'value' => "$re_desiredpay",'view' => "$view",'icon'=>"'Indicate desired annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)","size"=>"10"));
		$cpforms->maketextarea(array ('text' => "Other Compensation/Benefits",'id'=>"re_benefits",'name' => "re_benefits",'value' => stripslashes($re_benefits),'view' => "$view",'icon'=>"'Indicate other preferred compensation or benefits such as sign-on bonus or stock grants.  ', WIDTH, 200, SHADOW, true"));
		$cpforms->longline(array('title'=>"Qualifications"));
		$cpforms->maketextarea(array ('text' => "Schools Attended",'id'=>"re_schoolattend",'name' => "re_schoolattend",'value' => stripslashes($re_schoolattend),'view' => "$view"));

		$cpforms->makeselect(array ('one'=>1,'text' => "Years of Work Experience",'name' => "re_yearexp",'only' => 1,'option' => $yearexp2,'selected' => "$re_yearexp",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('one'=>1,'text' => "Highest Education Level",'name' => "re_edulevel",'only' => 1,'option' => $education,'selected' => "$re_edulevel",'view' => "$view",'viewfunction' => 'education','icon'=>"' Indicate the highest level of education achieved here.', WIDTH, 200, SHADOW, true"));
		$cpforms->gethightext(array ('text' => "Professional Licenses/Certification",'name' => "re_proflicense",'value' => "$re_proflicense",'view' => "$view",'icon'=>"'List all professional licenses or certifications obtained here.', WIDTH, 200, SHADOW, true"));
		$cpforms->makeselect(array ('one'=>1,'text' => "Years of People Mgmt Experience",'name' => "re_mgmt",'only' => 1,'option' => $yearexp2,'selected' => "$re_mgmt",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('one'=>1,'text' => "Years of Profit & Loss Responsibility",'name' => "re_profit",'only' => 1,'option' => $yearexp2,'selected' => "$re_profit",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->gethightext(array ('text' => "Spoken Language(s)",'name' => "re_spoken",'only' => 1,'value' => "$re_spoken",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Programming Language Knowledge",'name' => "re_prolang",'value' => "$re_prolang",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "High-Tech Patent/IP owner or Co-owner?",'name' => "re_ip",'only' => 1,'selected' => "$re_ip",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "U.S.Government Security Clearance?",'name' => "re_ussecurity",'only' => 1,'selected' => "$re_ussecurity",'view' => "$view"));
		$cpforms->maketextarea(array ('text' => "Authorized to work in the following country",'id'=>"re_authorize",'name' => "re_authorize",'only' => 1,'value' => "$re_authorize",'view' => "$view" ,'icon'=>"' Indicate in which country the candidate is authorized to work.', WIDTH, 200, SHADOW, true"));
		$cpforms->makefck(array ('text' => "Resume Detail",'name' => "re_detail",'id'=>"re_detail",'only' => 1,'value' => stripslashes($re_detail),'view' => "$view",'icon'=>"' Please include details of all relevant work experience, education and training here.  You can type-in your content or cut and paste them.  Please DO NOT include your name or contact information here. You may edit this later. Be sure to press the \'Shift\' and \'Enter\' keys to create single space lines.', WIDTH, 200, SHADOW, true"));
       	$cpforms->makefile(array ('text' => "Picture (Only accept image size less than 50KB.)",'name' => "uploadfile",'value'=>"$re_upload",'url'  => "uploadfiles/resumes/",'view' => "$view"));
		
		if($_SESSION[usertype]=="candidate"||$_SESSION[usertype]=="advisor"){
			$cpforms->longline(array('title'=>"More About Me…"));
			$cpforms->maketextarea(array ('text' => "My family/friends would describe me as…",'name' => "re_describeme",'id'=>"re_describeme",'value' => "$re_describeme",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My favoriate book is…because…",'name' => "re_favoriatebook",'id'=>"re_favoriatebook",'value' => "$re_favoriatebook",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My highest achievement is…",'name' => "re_highachieve",'id'=>"re_highachieve",'value' => "$re_highachieve",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "In 3 to 5 years, I plan to…",'name' => "re_iplan",'id'=>"re_iplan",'value' => "$re_iplan",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "When I'm not working I like to…",'name' => "re_iliketo",'id'=>"re_iliketo",'value' => "$re_iliketo",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My Personal Website or Blog Link ",'name' => "re_personalweb",'id'=>"re_personalweb",'value' => "$re_personalweb",'view' => "$view"));
			$cpforms->maketextarea(array ('text' => "Comments",'name' => "re_comments",'id'=>"re_comments",'only' => 0,'value' => stripslashes($re_comments),'view' => "$view",'icon'=>"'You may include additional comments here for view by recruiters.', WIDTH, 200, SHADOW, true"));
		}
		if($_SESSION[usertype]=="recruiter"){
		    $cpforms->longline(array('title'=>"Work Status, Employment and Professional References"));
			$cpforms->maketextarea(array ('text' => "Three Previous Employers",'id'=>"re_prvemployer",'name' => "re_prvemployer",'only' => 1,'value' => "$re_prvemployer",'view' => "$view",'icon'=>"'Please list 3 previous employers.', WIDTH, 200, SHADOW, true"));
		    $cpforms->gethighradio(array ('text' => "Previous Employment Status Checked?",'name' => "re_prvempstatus",'only' => 1,'selected' => "$re_prvempstatus",'view' => "$view",'icon'=>"'You are not required to perform employment status checking prior to submitting the applicant.  But it may improve your applicant\'s chances of being considered before other applicants.  Be ready to provide the necessary information if requested by the employer.', WIDTH, 200, SHADOW, true"));
			 $cpforms->gethighradio(array ('text' => "Three Professional References Available?",'name' => "re_professavilable",'only' => 1,'selected' => "$re_professavilable",'view' => "$view",'icon'=>"'Does the applicant have a minimum of 3 references available to speak of his/her past work performance?  This is not required but may improve your applicant\'s chances of being considered before others.  Be ready to provide the necessary information if asked by the employer.', WIDTH, 200, SHADOW, true"));
			 // $cpforms->gethighradio(array ('text' => "Will the applicant require work sponsorship for this job?",'name' => "re_sponsorship",'only' => 1,'selected' => "$re_sponsorship",'view' => "$view"));
		    $cpforms->longline(array('title'=>"Privacy Status"));
		    if($re_private==''){$re_private = 1;}
		}
			$cpforms->gethighradio(array ('text' => "Status",'name' => "re_private",'options'=>$pri_pub,'only' => 1,'selected' => "$re_private",'view' => "$view",'icon'=>"'By default all record(s) are hidden or is \'Private\' and viewable only by you.  If you wish to unhide your record or make it searchable by recruiters, then select the \'Public\' option. You may change this selection any time.', WIDTH, 200, SHADOW, true"));

			$cpforms->makePhpCaptcha(array('text'=>"Safe Code",'name'=>"imagecode",'value'=>"$_POST[imagecode]",'only'=>1));
		if($_GET[action]=='edit'||!empty($rs)){
           if(($_SESSION[usertype]=='candidate'&&!empty($rs))||($_SESSION[usertype]=='advisor'&&!empty($rs))){
			   $cpforms->formfooter(array (
				'confirm' => 3,
				're_id'   => $rs[re_id]
					));
		   }else{
		      $cpforms->formfooter(array (
				'confirm' => 3
		      ));
		   }
		}else{
			$cpforms->formfooter(array (
				'confirm' => 1
			));
		}

		$reg_data = ob_get_contents();
		ob_end_clean();

		if ($err != '')
		{
			$smarty->assign("err", $err);
		}
		$smarty->assign("reg", $reg_data);
        
		if($_SESSION[usertype]=='candidate'||$_SESSION[usertype]=='advisor'){//if candidate
					$title   = "My Resume";
					$content = "Promote your resume!  This is where you can post and edit your resume.  First, you must complete all of the required fields marked with an asterisk ‘*’.  If a required field does not apply to you, or you do not wish to disclose the information, then simply type in ‘NA’ to indicate not applicable.  Include as much detail as you can about your qualifications and the kind of job you desire. This way, recruiters on our site will contact you only about jobs most suitable for you.  You can include more information about yourself by completing the ‘More About Me…’ section.  Be sure to click on the ‘Save’ button to post your resume.  Once your resume profile is posted, it will be searchable by recruiter members on our site.  If you are no longer available for job opportunities, please be sure to change your ‘Job Search Status’ to ‘Do Not Contact’ (or delete your resume).  This way, recruiters will know to not contact you.  (<font color=red>*</font> = Required Field) ";
		}else{
		            $title   = "Add/Edit Candidate";
					$content = "Here you can add your candidates to our database so you may later submit them to open jobs on our site.  You may also want to add your candidates to our database so that other recruiters can find them and contact you for job split opportunities.  Once your candidates are added, recruiter members on our site will be able to search and find them.  Other recruiters may view your entire candidate record except for the candidate’s ‘email’ and ‘all the address and phone details’.  Anyone interested in your candidate must contact you first, so be sure to include your contact information in the ‘Recruiter Contact’ field.  By default, each candidate record posted will be private and confidential—in other words, only viewable by you and no one else—unless you select ‘Public’ for the privacy option, making the record viewable by others.  Only recruiter members on our site may find and view candidate records.  Be sure to click ‘Save’ to submit your record.  (<font color=red>*</font> = Required Field)";
		}

		if($_SESSION[uid] == $rs[re_uid] && $_SESSION[usertype] == "recruiter" ){
			$smarty->assign("aliasbutton",'<span style="float:right;padding: 0 10px 0 0 "><input type="button" value="Create Alias" onclick="location.href=\'postresumealias.php?id='.$rs[re_id].'\'"> <a href="###" onmouseover="Tip(\'You may create up to 99  alias copies of this candidate record.\', WIDTH, 200, SHADOW, true)"><img src="images/icn_question.jpg" border="0" align="absmiddle" /></a></span>');
		}

		$smarty->assign('title',$title);
		$smarty->assign('content',$content);
		$smarty->display('reg.tpl');


$smarty->display('allright.tpl');
$smarty->display('footer.tpl');
?>
